<template>
  <div class="nav">
    <el-menu
      background-color="#32415780"
      text-color="#bfcbd9"
      :default-active="this.$route.path"
      class="sidebar-el-menu"
      :collapse="collapse"
      router
      unique-opened
    >
      <el-submenu index="1">
        <template slot="title">
          <i class="el-icon-location"></i>
          <span>商品</span>
        </template>
        <el-menu-item index="/index">首页</el-menu-item>
        <el-menu-item index="/index/goodsManage">商品管理</el-menu-item>
        <el-menu-item index="/index/goodsAdd">添加商品</el-menu-item>
        <el-menu-item index="/index/goodsOutStock">结算商品</el-menu-item>
        <!--<el-menu-item-group title="分组2">-->
          <!--<el-menu-item index="1-3">选项3</el-menu-item>g-->
        <!--</el-menu-item-group>-->
        <!--<el-submenu index="1-4">-->
          <!--<template slot="title">选项4</template>-->
          <!--<el-menu-item index="1-4-1">选项1</el-menu-item>-->
        <!--</el-submenu>-->
      </el-submenu>
      <el-submenu index="2">
        <template slot="title">
          <i class="el-icon-location"></i>
          <span>订单管理</span>
        </template>
      <el-menu-item index="/index/salesList">
        <i class="el-icon-menu"></i>
        <span slot="title">销售列表</span>
      </el-menu-item>
      </el-submenu>
    </el-menu>
  </div>
</template>
<script>
import bus from "../bus.js";
export default {
  data() {
    return {
      collapse: false,
      navMenu: []
    };
  },
  created() {
    // 通过 Event Bus 进行组件间通信，来折叠侧边栏
    bus.$on("collapse", msg => {
      this.collapse = msg;
    });
    //发送ajax获取菜单信息
    // this.req
    //   .get("/account/role")
    //   .then(response => {
    //     //将接受到的导航数据赋值给navMenu
    //     this.navMenu = response.data;
    //   })
    //   .catch(err => {
    //     console.log(err);
    //   });
  }
};
</script>
<style lang="less">
.nav {
  .sidebar-el-menu {
    height: 100%;
    border: none;
    .el-menu-item {
      background-color: transparent !important;
    }
    .el-menu-item:hover {
      background-color: #324157 !important;
    }
    .el-submenu {
      .el-submenu__title,
      .el-menu {
        background-color: transparent !important;
        .el-menu-item {
          background-color: transparent !important;
        }
      }
      .el-submenu__title:hover,
      .el-menu .el-menu-item:hover {
        background-color: #324157 !important;
      }
    }
  }
  .sidebar-el-menu:not(.el-menu--collapse) {
    width: 200px;
  }
}
.el-menu--vertical {
  .el-menu--popup {
    padding: 0;
    .el-menu-item {
      background-color: transparent !important;
    }
  }
}
.el-menu--vertical {
  .el-menu--popup {
    .el-menu-item:hover {
      background-color: #324157 !important;
    }
  }
}
</style>


